home *** CD-ROM | disk | FTP | other *** search
/ Aminet 33 / Aminet 33 - October 1999.iso / Aminet / util / cli / cliutils_mra.lha / Sources / DFree / DFree.a next >
Encoding:
Text File  |  1997-06-17  |  4.4 KB  |  209 lines

  1. ;
  2. ; $VER: DFree.a V1.0 recoded in 100% assembly
  3. ;
  4. ; Started: 02/12/1996 (month/day/year)
  5. ;
  6. ; Original by Max Francis, coded in C (6200 bytes!)
  7. ; USAGE: dfree <device/name>
  8. ;
  9. ; 100% assembly recoded version by Mauro Panigada (FREEWARE)
  10. ; USAGE: dfree <device/name>
  11. ;
  12. ; Semplified line parser. Shorter than original C version.
  13. ;
  14. ; STORY: DFree V1.0 (02/12/1996) simply a remake from C version.
  15. ;
  16. ; GOOD QUALITY: Differently from shorter DSpace V1.2 (freeware), DFree
  17. ; works with 68000 (no odd addresses, and uses utility.library for
  18. ; 32bit operations and not the 68020 mulu.l istruction), and it
  19. ; calculate the best method to rapresent the free space (bytes, Kilo or
  20. ; Mega). Is it enough?
  21. ;
  22.  
  23.  
  24.         incdir    "dh0:progr/assem/include/"
  25.         include    "exec/types.i"
  26.         include    "exec/libraries.i"
  27.         include    "exec/exec_lib.i"
  28.         include    "dos/dos.i"
  29.         include    "dos/dosextens.i"
  30.         include    "dos/dos_lib.i"
  31.         include    "utility/utility_lib.i"
  32.  
  33.  
  34.         bra.b    start
  35.  
  36. prg_version    dc.b    "$VER: DFree V1.0 recoded in 100% assembly "
  37. unknow_reauthor    dc.b    "by Mauro Panigada",0
  38.         even
  39.  
  40. LIBVERSION    EQU    37        ; 2.04 ? non ricordo mai!
  41.  
  42. start        movem.l    d0/a0,-(sp)
  43.         moveq    #0,d7
  44.         move.l    4.w,a6
  45.         lea    dosname(pc),a1
  46.         moveq    #LIBVERSION,d0
  47.         jsr    _LVOOpenLibrary(a6)
  48.         tst.l    d0
  49.         bne.b    vaicosi
  50.         adda.w    #8,sp
  51.         rts
  52.  
  53. closeall0    move.l    a5,a6
  54.         suba.l    a5,a5
  55.         bra    closeall
  56.  
  57. vaicosi        move.l    d0,a5
  58.         lea    utilname(pc),a1
  59.         moveq    #LIBVERSION,d0
  60.         jsr    _LVOOpenLibrary(a6)
  61.         tst.l    d0
  62.         beq.b    closeall0
  63.         move.l    d0,a6
  64.         exg.l    a5,a6        ; a6=dos, a5=utility
  65.         movem.l    (sp)+,d0/a0
  66.         cmp.b    #1,d0
  67.         beq    helpscreen
  68.         cmp.b    #"?",(a0)
  69.         beq    helpscreen
  70.                     ; no with "HELP" or "help"...
  71.         clr.b    -1(a0,d0)
  72.         move.l    a0,a1        ; line parser
  73.         move.w    d0,d1        ; molto semplice e
  74.         subq.w    #1,d1        ; rudimentale; capisce le
  75. spcloop0    cmp.b    #" ",(a1)+    ; virgolette (") e salta
  76.         dbne    d1,spcloop0    ; gli spazi...
  77.         cmp.b    #'"',-1(a1)
  78.         bne.b    nearpar
  79.         move.l    a1,a0
  80. spcloop        cmp.b    #'"',(a1)+
  81.         dbeq    d1,spcloop
  82.         clr.b    -1(a1)
  83.         bra.b    lineparsed
  84. nearpar        move.l    a1,a0
  85.         suba.w    #1,a0
  86. spcloop1    cmp.b    #" ",(a1)+
  87.         dbeq    d1,spcloop1
  88.         clr.b    -1(a1)
  89.  
  90. lineparsed    lea    parg(pc),a1
  91.         move.l    a0,(a1)
  92.                     ; no to upper...
  93.         move.l    a0,d1
  94.         moveq    #ACCESS_READ,d2
  95.         jsr    _LVOLock(a6)
  96.         move.l    d0,d7        ; d7=lock
  97.         beq    lockerror
  98.         lea    idstruct(pc),a0
  99.         move.l    a0,d2
  100.         move.l    d0,d1
  101.         jsr    _LVOInfo(a6)
  102.         tst.l    d0
  103.         beq    infoerror
  104.         lea    idstruct(pc),a4            ; a4=info data
  105.         move.l    id_NumBlocks(a4),d3
  106.         move.l    id_NumBlocksUsed(a4),d4
  107.         move.l    id_BytesPerBlock(a4),d5
  108.         sub.l    d4,d3
  109.         exg.l    a5,a6            ; a6=utility
  110.         move.l    d3,d0
  111.         move.l    d5,d1
  112.         jsr    _LVOUMult32(a6)
  113.         exg.l    a5,a6
  114.         move.l    d0,d6
  115.         lea    tharg(pc),a0
  116.         cmp.l    #(5*1048576),d6
  117.         bhi    megafree
  118.         cmp.l    #1024,d6
  119.         blo    bytefree
  120. kappafree    lea    kappa.msg(pc),a1
  121.         move.l    a1,(a0)
  122.         move.l    d6,d0
  123.         move.l    #1024,d1
  124.         bra.b    shwrite0
  125. bytefree    lea    byte.msg(pc),a1
  126.         move.l    a1,(a0)
  127.         bra.b    shwrite
  128. megafree    lea    mega.msg(pc),a1
  129.         move.l    a1,(a0)
  130.         move.l    #1048576,d1
  131. shwrite0    exg.l    a5,a6
  132.         move.l    d6,d0
  133.         jsr    _LVOUDivMod32(a6)
  134.         move.l    d0,d6
  135.         exg.l    a5,a6
  136. shwrite        lea    secarg(pc),a0
  137.         move.l    d6,(a0)
  138.         lea    string(pc),a0
  139.         move.l    a0,d1
  140.         lea    parg(pc),a0
  141.         move.l    a0,d2
  142.         jsr    _LVOVPrintf(a6)
  143. closeall    move.l    d7,d1
  144.         beq.b    closenext1
  145.         jsr    _LVOUnLock(a6)
  146. closenext1    move.l    a6,d0
  147.         beq.b    closenext2
  148.         move.l    d0,a1
  149.         movea.l    4.w,a6
  150.         jsr    _LVOCloseLibrary(a6)
  151. closenext2    move.l    a5,d0
  152.         beq.b    okciao
  153.         move.l    d0,a1
  154.         move.l    4.w,a6
  155.         jsr    _LVOCloseLibrary(a6)
  156. okciao        rts
  157.  
  158. helpscreen    lea    help.msg(pc),a0
  159.         lea    myarg(pc),a1
  160.         lea    arg.msg(pc),a2
  161.         move.l    a2,(a1)
  162.         move.l    a1,d2
  163. writerror    move.l    a0,d1
  164.         jsr    _LVOVPrintf(a6)
  165.         bra    closeall
  166.  
  167. lockerror    lea    lock.msg(pc),a0
  168.         lea    parg(pc),a1
  169.         move.l    a1,d2
  170.         bra.b    writerror
  171.  
  172. infoerror    lea    info.msg(pc),a0
  173.         lea    parg(pc),a1
  174.         move.l    a1,d2
  175.         bra.b    writerror
  176.  
  177. ;---------------------------------------------------------------------------
  178. dosname        dc.b    "dos.library",0
  179.         even
  180. utilname    dc.b    "utility.library",0
  181.         even
  182. help.msg    dc.b    "DFree V1.0 recoded in 100%% assembly"
  183.         dc.b    " by Mauro Panigada (02/12/1996)",10
  184.         dc.b    "Original version coded in C by Max Francis",10
  185.         dc.b    "USAGE: %s <DEVICE/DISK>",10
  186.         dc.b    "Show free disk space on DEVICE or DISK "
  187.         dc.b    "specified.",10,0
  188.         even
  189. lock.msg    dc.b    "Can't lock %s",10,0
  190.         even
  191. info.msg    dc.b    "Can't examine %s",10,0
  192.         even
  193. parg        dc.l    0
  194. secarg        dc.l    0
  195. tharg        dc.l    0
  196. myarg        dc.l    0
  197. arg.msg        dc.b    "DFree",0
  198.         even
  199. string        dc.b    "%s %ld%s free.",10,0
  200.         even
  201. byte.msg    dc.b    " bytes",0
  202.         even
  203. mega.msg    dc.b    "M",0
  204.         even
  205. kappa.msg    dc.b    "K",0
  206.         cnop    0,4        ; doc dice longword alligned (!)
  207. idstruct    ds.b    id_SIZEOF
  208.  
  209.         END